﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using IURIP;

namespace URIP.Core
{
    [Serializable]
    public class Process : BaseRunable, IProcess
    {
        public Process(ITemplate template, IRunable parentRunable)
            : base(template, parentRunable)
        {

        }

        [NonSerialized]
        protected bool m_stopped = false;

        public XmlNode OriginalDataXml
        {
            get;
            set;
        }
        public XmlDocument TargetDataXml
        {
            get;
            set;
        }
        public IFilter FilterFromTargetRelationship
        {
            get;
            set;
        }
        public string KeyFromTargetRelationship
        {
            get;
            set;
        }
        public bool Stopped
        {
            get { return m_stopped; }
        }
        public string RawKey
        {
            get;
            set;
        }

        public void Stop()
        {
            m_stopped = true;
        }
        protected override void RunAssis()
        {
            Task.Logger.LogDebug("Start running process for target '{0}'", Target.Name);

            this.RunHelper(this.GetFirstChildNode(), TargetDataXml);

            Task.Logger.LogDebug("Finish process for target '{0}'", Target.Name);

            Task.Logger.Log("[Target]:{0} finished===========================================", ELogLevel.Demo, Target.Name);
        }
    }
}
